﻿@{
    if (!UrlData.Any()) {
        RequestData.SetValue("InfoPaneTitle", "Invalid Event Id");
        return;
    }

    int eventId = UrlData[0].AsInt();

    var eventInfo = Event.GetUserEvent(WebSecurity.CurrentUserId, eventId);

    if (eventInfo == null) {
        RequestData.SetValue("InfoPaneTitle", "Invalid Event Id");
        return;
    }

    if (eventInfo.Permissions < (int)Permission.Edit) {
        RequestData.SetValue("InfoPaneTitle", "No Permissions to Delete Event " + eventId);
        return;
    }

    RequestData.SetValue("InfoPaneTitle", "Delete Event: " + eventInfo.Name);

    // We have confirmed that we want to delete
    if (IsPost) {
        Event.DeleteEvent(eventId);
        Response.Redirect("~/");
    }
}
<div class="confirm">
    <div class="message center">
        Are you sure that you want to delete the event "@eventInfo.Name"?
    </div>
    <form action="" method="post">
        <div class="actions center">
            <input type="submit" value="Confirm" />
        </div>
    </form>
</div>